/* 
 * File:   CollisionEvents.h
 * Author: RedEyedKiller
 *
 * Created on 5 Νοέμβριος 2010, 8:47 πμ
 */

#ifndef COLLISIONEVENTS_H
#define	COLLISIONEVENTS_H

#include "../Mathematics.h"
#include "../Utilities.h"
#include "../PhysicsLogic.h"
#include "../Entity.h"
#include "../Vector2.h"
#include "Contact.h"

namespace physicsSystem
{

namespace PhysicsInternals
{

enum Axis
{
    AXIS_X,
    AXIS_Y,
    AXIS_INVALID
};

/**
 * A struct to represent a bountary entry.
 */
struct RDCBoundaryEntry
{
    /**
     * The holding object.
     */
    EntitySystem::PhysicsLogic* object;
    
    /**
     * The position of the entry on the specified axis. (no need to hold the axis here)
     */
    int posInAxis;
    
    /**
     * Indicates if this entry is where the object starts or ends.
     */
    bool open;
};

/**
 * A Comparator to use with std::sort.
 * Default () operator returns true if i should go before j.
 */
struct ComparePhysics
{
    bool operator() (EntitySystem::PhysicsLogic* i, EntitySystem::PhysicsLogic * j)
    {
        return (i->GetParent()->GetPositionX() < j->GetParent()->GetPositionX());
    }
};

/**
 * A Comparator to use with std::sort.
 * Default () operator returns true if i should go before j.
 */
struct CompareBoundaryEntries
{
    bool operator() (const RDCBoundaryEntry& i,const RDCBoundaryEntry& j)
    {
        return (i.posInAxis < j.posInAxis);
    }
};

struct CompareContacts
{
    //returns true if the first argument is to be considered less than the second argument, and false otherwise.
    bool operator() (const Contact& a,const Contact& b)
    {
		return (a.GetGroup() < b.GetGroup());
    }
};


struct TileColEvent
{
    TileColEvent()
    {
        tile = 0;
    }
    unsigned long tile;
    Math::Rect region;
};

}; /*namespace*/
}; /*namespace*/
#endif	/* COLLISIONEVENTS_H */

